<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>添加科目</title>
    <link href="${request.contextPath}/static/ihomeStatic/css/bootstrap.min.css" rel="stylesheet">
    <link href="${request.contextPath}/static/ihomeStatic/js/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="${request.contextPath}/static/ihomeStatic/css/font-awesome.min.css" rel="stylesheet">
    <link href="${request.contextPath}/static/ihomeStatic/css/animate.min.css" rel="stylesheet">
    <link href="${request.contextPath}/static/ihomeStatic/css/style.min.css" rel="stylesheet">
    <link href="${request.contextPath}/static/ihomeStatic/js/layer/mobile/need/layer.css" rel="stylesheet">
    <link href="${request.contextPath}/static/ihomeStatic/js/treeTable/css/treeTable.min.css" rel="stylesheet">
    <script type="text/javascript">
        var ctx = "";
        var __cityId = "";
    </script>
</head>
<body>
<div class="wrapper white-bg">
    <div class="row">
        <div class="col-lg-12">
            <div class="tab-content">
                <div id="tab-10" class="tab-pane active">
                    <div class="panel-body">
                        <div class="row">
                            <form class="form-horizontal" id="defaultForm" method="post" action="${request.contextPath}/dict/city/provinceForm/save"
                                  onsubmit="return false;">


                                <div class="row">

                                    <div class="col-sm-6">
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label"><font color="red">*</font>科目名称:</label>
                                            <div class="col-sm-8"><input type="text" class="form-control required" id="courseName" name="courseName" value="">
                                            </div>
                                        </div>
                                    </div>


                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">图片</label>
                                        <div class="col-sm-10">
                                            <div class="input-group">
                                                <input id="questionImageUrl" name="questionImageUrl" type="text" class="form-control">
                                                <span class="input-group-btn">
                                                <button type="button" class="btn btn-primary" id="selectImage"
                                                        data-toggle="modal" data-target="#selectImageModal">上传图片</button>
                                    </span>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="col-sm-6">
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label"><font color="red">*</font>原价:</label>
                                            <div class="col-sm-8"><input type="text" class="form-control required" id="originalPrice" name="originalPrice" value="">
                                            </div>
                                        </div>
                                    </div>

                                    <div class="col-sm-6">
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label"><font color="red">*</font>活动价:</label>
                                            <div class="col-sm-8"><input type="text" class="form-control required" id="activityPrice" name="activityPrice" value="">
                                            </div>
                                        </div>
                                    </div>

                                    <div class="col-sm-6">
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label"><font color="red">*</font>排序:</label>
                                            <div class="col-sm-8"><input type="text" class="form-control required" id="sort" name="sort" value="">
                                            </div>
                                        </div>
                                    </div>

                                    <div class="col-sm-6">
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label"><font color="red">*</font>是否为付费内容:</label>
                                            <input type="radio" name="isPaid" class="x1" value="Y" checked/>付费

                                            <input type="radio" name="isPaid" class="x1" value="N"/>免费
                                            <div id="div1"></div>
                                        </div>
                                    </div>

                                    <div class="col-sm-6">
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label"><font color="red">*</font>状态:</label>

                                                <input type="radio" name="status" class="x2" value="Y" />有效

                                                <input type="radio" name="status" class="x2" value="N"checked/>无效
                                            <div id="div2"></div>
                                        </div>
                                    </div>
                                </div>


                                <div class="row">
                                    <div class="col-md-6">
                                        <div class="form-group"><label class="col-sm-2 control-label">备注：</label>

                                            <div class="col-sm-10 width450">
                                                <textarea id="remark" class="form-control" rows="3"></textarea>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </form>
                            <button onclick="enter()" class="btn btn-success">确定</button> <button onclick="cancel()" class="btn btn-primary">取消</button>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script src="${request.contextPath}/static/ihomeStatic/js/jquery-1.12.4.js"></script>
<script src="${request.contextPath}/static/ihomeStatic/js/bootstrap.min.js"></script>
<script src="${request.contextPath}/static/ihomeStatic/js/bootstrap-table/bootstrap-table.min.js"></script>
<script src="${request.contextPath}/static/ihomeStatic/js/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="${request.contextPath}/static/ihomeStatic/js/layer/layer.js"></script>
<script src="${request.contextPath}/static/ihomeStatic/js/treeTable/js/jquery.treeTable.min.js"></script>
<script type="text/javascript" src="${request.contextPath}/static/js/plugins/upload/js/diyUpload.js"></script>
<script src="${request.contextPath}/static/js/plugins/upload/tookeen.js"></script>
<script>





    function enter() {
        var courseName = $("#courseName").val();
        var questionImageUrl = $("#questionImageUrl").val();
        var originalPrice = $("#originalPrice").val();
        var activityPrice = $("#activityPrice").val();
        var sort = $("#sort").val();
        var isPaid = $("input[name='isPaid']:checked").val();
        var status = $("input[name='status']:checked").val();
        var remark = $("#remark").val();
        $.ajax({
            url:"${request.contextPath}/courseManage/add",
            type:"POST",
            data:{courseName:courseName,imageUrl:questionImageUrl,originalPrice:originalPrice,activityPrice:activityPrice,sort:sort,isPaid:isPaid,status:status,remark:remark},
            success:function (data) {
                if (data.returnCode!=null||data.returnCode!=''){
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.$("#hi1").val("1");
                    parent.layer.close(index);//关闭当前页
                }
            }
        });

    }
    function cancel() {
        parent.$("#hi1").val("2");
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);//关闭当前页
    }


    $(document).ready(function () {
        $("#selectImage").click(function () {
            openButtonWindow("上传图片", ctx + '/fileUpload/toUploadImage', 600, 400, '完成',setImageUrl);
        });
    });

    function setImageUrl() {
        var imageUrl = $("#questionImageUrl").val();
        if(localStorage.imageUrl){
            if(imageUrl){
                imageUrl += ","+localStorage.imageUrl;
            }else{
                imageUrl= localStorage.imageUrl;
            }
            $("#questionImageUrl").val(imageUrl);
            localStorage.removeItem("imageUrl");
        }
    }



</script>


</html>
